<?php

//<editor-fold defaultstate="collapsed" desc="License & Copyright">
/*
 * @license
 */

/**
 *
 * @author Jevgeni Geimanen (jevgeni.geimanen@gmail.com)
 */
//</editor-fold>
class SCIniHelper {

    public static function parseIniFile($path) {
        $ini = parse_ini_file($path, true);

        $res = array();
        $matches = array();
        foreach ($ini as $k => $subini) {
            $res[$k] = array();
            foreach ($subini as $key => $val) {
                $keys = preg_split("/\./", $key);
                $rr = array();
                $r = &$rr;
                while (($count = count($keys)) > 0 && ($newKey = array_shift($keys))) {
                    $r[$newKey] = $count > 1 ? array() : $val;
                    $r = &$r[$newKey];
                }
                $res[$k] = array_merge_recursive($res[$k], $rr);
            }
        }
        return $res;
    }

}

?>
